package com.king.designpatterns.hybriddesignpattern.hybriddesignpattern.specificationpattern;

/**
 * @author king
 * @date 2021-06-16 16:33
 */
public class AndSpecification extends CompositeSpecification{
    // 传递两个规格书进行and操作
    private IUserSpecification left;
    private IUserSpecification right;

    public AndSpecification(IUserSpecification left, IUserSpecification right) {
        this.left = left;
        this.right = right;
    }

    /**
     * 实现and校验方法
     */
    @Override
    public boolean isSatisfiedBy(User user) {
        return left.isSatisfiedBy(user) && right.isSatisfiedBy(user);
    }
}
